import { get, post, upload } from "../request/http"
//  获取文章列表
export const fetchArticleList = (data: Record<string, any>):  Promise<any> => {
  return post('/article/list', { ...data })
}

// 获取文章详情
// export const fetchArticleDetail = (id: string):  Promise<any> => {
//   return get('/article/detail', { id })
// }
export const fetchArticleDetail = (id: string|number): Promise<any> => {
  return get(`/article/detail/${id}`)
}

// 编辑文章
// export const updateArticle = (data: Record<string, any>, config?:Record<string, unknown>):  Promise<any> => {
//   return post('/article/save', { ...data }, config)
// }

export const updateArticle = (
  data: FormData,
): Promise<any> => {
  return upload('/article/save', data)
}

// 删除文章
export const deleteArticle = (id: string|number):  Promise<any> => {
  return post('/article/delete', { id })
}

// 文章分类列表
export const fetchArticleCategoryList = (data: Record<string, any>):  Promise<any> => {
  return post('/category/list', { ...data })
}

// 添加文章分类
export const addArticleCategory = (data: Record<string, any>):  Promise<any> => {
  return post('/category/add', { ...data })
}

 // 修改文章分类
 export const updateArticleCategory = (data: Record<string, any>):  Promise<any> => {
  return post('/category/update', { ...data })
}

// 删除文章分类
export const deleteArticleCategory = (id: string):  Promise<any> => {
  return post('/category/delete', { id })
}

// 获取标签列表
export const getTagList = (data: Record<string, any>): Promise<any> => {
  return get('/tag/list', { ...data })
}

 // 添加标签
 export const addTag = (data: Record<string, any>):  Promise<any> => {
  return post('/tag/add', { ...data })
}

 // 修改标签
 export const updateTag = (data: Record<string, any>):  Promise<any> => {
  return post('/tag/update', { ...data })
}

 // 删除标签
 export const deleteTag = (id: string):  Promise<any> => {
  return post('/tag/delete', { id })
}
